package com.fafi.rxjava1;

import com.fafi.rxjava1.observeon.OperatorCallbackOn;
import com.fafi.rxjava1.subscribeon.OperatorCallOn;
import com.fafi.rxjava1.subscribeon.Switcher;

public class Caller<T> {
    final OnCall<T> onCall;


    public Caller(OnCall<T> onCall) {
        this.onCall = onCall;
    }

    /**
     * 解释:对于声明了<T>的类(Caller<T>就是声明了<T>的类)不需要声明泛型方法,
     * 对于带了static的方法,它并不属于类的一部分,所以相当于没有声明<T>的类,
     * 所以需要声明为泛型方法.
     * @param onCall
     * @param <T>
     * @return
     */
    public static <T> Caller<T> create(OnCall<T> onCall) {
        return new Caller<>(onCall);
    }

    public Calling call(Receiver<T> receiver) {
        this.onCall.call(receiver);
        return receiver;
    }

    public interface OnCall<T> extends Action1<Receiver<T>> {
    }


}
